package cn.com.generaldata.os.service.intf;

import java.io.File;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.hibernate.criterion.DetachedCriteria;

import cn.com.generaldata.jsme_indicator_system.entity.ReportTypeLimit;
import cn.com.generaldata.jsme_indicator_system.entity.ReportTypeUnit;
import cn.com.generaldata.jsme_indicator_system.entity.SummaryReportType;
import cn.com.generaldata.jsme_indicator_system.vo.reportdesigner.ReportExcelSectionVO;
import cn.com.generaldata.os.newpojo.ReportType;
import cn.com.generaldata.os.newpojo.ReportVersion;
import cn.com.generaldata.os.paging.Filter;
import cn.com.generaldata.os.paging.Page;
import cn.com.generaldata.os.paging.Result;
import cn.com.generaldata.os.pojo.Report;
import cn.com.generaldata.os.pojo.ReportAttach;
import cn.com.generaldata.os.pojo.ReportDetail;
import cn.com.generaldata.os.pojo.ReportUnit;
import cn.com.generaldata.os.pojo.Unit;
import cn.com.generaldata.os.pojo.User;
import cn.com.generaldata.os.pojo.mvc.Row;
import cn.com.generaldata.os.vo.DynamicReportVO;
import cn.com.generaldata.os.vo.ReportPerformVO;

public interface ReportServiceInterface {

	/**
	 * @function 供Spring Controller调用的创建报表的方法
	 * @param report
	 *            mvc包下的report
	 * @return
	 *         @
	 */
	String createMVCReport(cn.com.generaldata.os.pojo.mvc.Report report);

	void modiReportAttachsDisposal(String[] ids);

	void modiAttachDisposal(String attachId, String attachDisposal);

	Result queryReportsByParent(String reportProxyId, String userId, Short checkStatus, String reportSystem,
			String reportTypeCode, String reportVersion, Date startingReportDate, Date endingReportDate, String areaId,
			Integer pageNum, Page page, String typeNo);

	Result queryReportsByProxy(String reportProxyId, String userId, Short checkStatus, String reportSystem,
			String reportTypeCode, String reportVersion, Date startingReportDate, Date endingReportDate, String areaId,
			Integer pageNum, Page page, String flag, String typeNo, String unitName);

	int queryReportsByBillboardTime(String typeCode, String timeType, String yearType, String quarterDate,
			String billboardTime, String reportVersion, String units);

	List<Report> queryReportsByBillboardUser(String typeCode, String timeType, String yearType, String quarterDate,
			String billboardTime, String reportVersion, String user);

	public List<ReportTypeLimit> queryReportLimit(Integer statSystem, String reportTypeId, String typeTime,
			String typeYear);

	Result queryReportsByQBC(DetachedCriteria dc, Page page);

	void saveReportUtil(String reportId, String unitId, Short checkStatus, String areaId);

	String addReportAttachments(ReportAttach reportAttach);

	Result queryReportAttach(Filter filter, Page page);

	ReportAttach queryReportAttachById(String id);

	// 自加
	String createMVCReport4Mark(cn.com.generaldata.os.pojo.mvc.Report report);

	Result queryReportsHql(String hql, Page page, Object... paras);

	/**
	 * @function 供Spring Controller调用的修改报表的方法
	 * @param report
	 *            mvc包下的report
	 * @return
	 *         @
	 */
	cn.com.generaldata.os.pojo.mvc.Report modifyMVCReport(cn.com.generaldata.os.pojo.mvc.Report report);

	/**
	 * @function 供Spring Controller调用的查询报表的方法
	 * @param id
	 * @return
	 */
	cn.com.generaldata.os.pojo.mvc.Report queryMVCReportById(String id);

	/**
	 * @function 创建报表
	 * @param report
	 * @return 主键
	 */
	String createReport(Report report);

	/**
	 * @function 更新报表
	 * @param report
	 * @return 更新后的报表
	 */
	Report modifyReport(Report report);

	/**
	 * @function 根据主键查询报表
	 * @param id
	 * @return
	 */
	Report queryReportById(String id);

	/**
	 * @Function 查询供自动审核的报表对象
	 * @param reportUnit
	 *            填报单位
	 * @param reportTypeCode
	 * @param reportYear
	 *            报表年
	 * @param reportQuarter
	 *            报表季度，对于海核表，reportQuarter处填写上半年或下半年 常量表示： 上半年 --
	 *            ReportConstant.THE_FIRST_HALF_OF_THE_YEAR 下半年 --
	 *            ReportConstant.THE_SECOND_HALF_OF_THE_YEAR
	 * @return
	 * 
	 * @author Stoner.Wong 2011-7-4
	 */
	cn.com.generaldata.os.pojo.mvc.Report queryReport2AutoValidate(String reportUnit, String reportTypeCode,
			String reportYear, String reportQuarter);

	List<ReportUnit> queryReportUnit(Filter filter);

	/**
	 * @function 根据查询条件查询报表
	 * @param filter
	 *            查询条件对象
	 * @param page
	 *            分页信息对象
	 * @return
	 */
	Result queryReports(Filter filter, Page page);

	/**
	 * @function 删除报表
	 * @param ids
	 * @return
	 */
	void removeReports(String[] ids);

	/**
	 * @Function 提交报表
	 * @param report
	 * @param operatorId
	 * @return 持久化后的主键值
	 */
	String submitReport(cn.com.generaldata.os.pojo.mvc.Report report);

	/**
	 * @function 审核通过
	 * @param reportId
	 * @param operatorId
	 * @param checkComment
	 * @param checkResult
	 */
	void passReport(cn.com.generaldata.os.pojo.mvc.Report reportMVC, String operatorId, Short checkStatus,
			String checkComment, String checkResult);

	/**
	 * @function 保存审核意见
	 * @param reportId
	 * @param operatorId
	 * @param checkComment
	 * @param checkResult
	 */
	void saveAudit(cn.com.generaldata.os.pojo.mvc.Report reportId, String operatorId, Short checkStatus,
			String checkComment);

	void removeReportAttachs(String[] ids);

	/**
	 * @function 驳回报表
	 * @param reportId
	 * @param operatorId
	 * @param checkComment
	 * @param checkResult
	 */
	void rejectReport(cn.com.generaldata.os.pojo.mvc.Report reportMVC, String operatorId, Short checkStatus,
			String checkComment, String checkResult);

	String createReportDetail(ReportDetail reportDetail);

	ReportDetail modifyReportDetail(ReportDetail reportDetail);

	ReportDetail queryReportDetailById(String id);

	Result queryReportDetails(Filter filter, Page page);

	void removeReportDetails(String[] ids);

	/**
	 * @function 创建报表类型
	 * @param reportType
	 * @return 主键
	 */
	String createReportType(ReportType reportType);

	/**
	 * @function 更新报表类型
	 * @param reportType
	 * @return 更新后的报表类型
	 */
	ReportType modifyReportType(ReportType reportType);

	/**
	 * @function 根据主键查询报表类型
	 * @param id
	 * @return
	 */
	ReportType queryReportTypeById(String id);

	/**
	 * @function 根据用户ID，报表类型，时段判断此时段的报表是否可以添加
	 * @param typeCode, timeType, timeValue, quarterDate
	 * @return
	 */
	boolean isReportTimeType(User user, String typeCode, String timeType, String yearType, String timeValue,
			String quarterDate, String reportVersion);

	/**
	 * @function 根据报表时段获取报表信息
	 * @param typeCode, timeType, timeValue, quarterDate
	 * @return
	 */
	public Map getLasttimeReportByTimetype(User user, ReportType reportType, String timeDate, String quarterDate);

	/**
	 * @function 根据属性代码查询报表类型
	 * @param typeCode
	 * @return
	 */
	ReportType queryReportTypeByTypeCode(String typeCode);

	/**
	 * @Function 根据行业ID查询所有报表类型
	 * @param industryId
	 * @return
	 */
	List<ReportType> queryReportTypeByIndustryId(String industryId);

	/**
	 * @function 根据查询条件查询报表类型
	 * @param filter
	 *            查询条件对象
	 * @param page
	 *            分页信息对象
	 * @return
	 */
	Result queryReportTypes(Filter filter, Page page);

	/**
	 * @function 获取报表版本的最大版本数值
	 * @param filter
	 *            查询条件对象
	 * @param page
	 *            分页信息对象
	 * @return
	 */
	String queryReportMaxVersion(Filter filter, Page page);

	/**
	 * @function 获取报表版本的所有信息
	 * @param filter
	 *            查询条件对象
	 * @param page
	 *            分页信息对象
	 * @return
	 */
	public Result queryReportVersion(Filter filter, Page page);

	/**
	 * @function 根据报表制度获取当前报表版本信息
	 * @param filter
	 *            查询条件对象
	 * @return
	 */
	ReportVersion getVersion(Filter filter, Page page);

	/**
	 * @function 删除报表类型
	 * @param ids
	 * @return
	 */
	void removeReportTypes(String[] ids);

	Report toPersistReport(cn.com.generaldata.os.pojo.mvc.Report report);

	/**
	 * @function 根据地区ID号，获取当前地区下所有子地区的ID号数组
	 * @param ids
	 * @return
	 */
	String[] getSubAreaIds(String parentAreaId);

	/**
	 * 按照模板导入报表
	 * 
	 * @param user
	 * @param reportProxyId
	 * @param rType
	 * @param timeType
	 * @param yearType
	 * @param timeDate
	 * @param unitIndustryId
	 * @param reportVersion
	 * @param quarterDate
	 * @param file
	 * @param sectionInfo
	 * @param lasttimeReport
	 */
	String import_report(User user, String reportProxyId, cn.com.generaldata.os.newpojo.ReportType rType,
			String timeType, String yearType, String timeDate, String unitIndustryId, String reportVersion,
			String quarterDate, File file, ReportExcelSectionVO sectionInfo) throws Exception;

	/**
	 * 根据企业和报表时段查绩效
	 * 
	 * @param unitId
	 * @param timeType
	 * @param type
	 */
	List<ReportPerformVO> reportAccount(String areaId, String timeType, String type);

	/**
	 * 查询催报延长时间
	 * 
	 * @param reportTypeId
	 * @param unitId
	 * @param timeType
	 * @param yearType
	 * @param timeDate
	 * @param quarter
	 * @return
	 */
	Integer queryBillByReport(String reportTypeId, String unitId, String timeType, String yearType, String timeDate,
			String quarter);

	Result queryReportAttachByHql(String hql, HashMap map, Page page);

	/**
	 * 自动提醒
	 * 
	 * @param unitId
	 * @return
	 */
	List<cn.com.generaldata.os.vo.ReportVO> reportAlert(String unitId);

	/**
	 * 查询汇总指标
	 * 
	 * @param user
	 * @param reportType
	 * @param timeDate
	 * @param quarterDate
	 * @return
	 */
	Map getReportAccounting(User user, ReportType reportType, String timeDate, Integer quarterDate);

	/**
	 * 汇总行式报表
	 * 
	 * @param user
	 * @param reportType
	 * @param timeDate
	 * @param quarter
	 * @return
	 */
	List<Row> getRowsAccounting(User user, ReportType reportType, String timeDate, Integer quarter);

	/**
	 * 指标对比
	 * 
	 * @param user
	 * @param reportType
	 * @param timeDate
	 * @param quarter
	 * @return
	 */
	Map getReportIndicator(User user, ReportType reportType, Date timeDate, Integer quarter, Map accounting);

	void createReportAccount(String areaId, String timeDate, String type);

	Result queryAllReport(String areaId, String unitName, String reportSystem, String reportTypeId, String industryId,
			String reportVersion, Date startingReportDate, Date endingReportDate, Integer pageNum, Page page,
			String status, String typeNo);

	Result queryReportTypeByHql(String hql, HashMap map, Page page);

	List<String> queryReportTypesUnit(String unitId);

	List<String> queryTypeNo(Integer type);

	List<String> generelReportsDetail(String areaId, ReportType rType, String timeDate, String quarterDate);

	ReportType getTypeId(String typeNo, String typeName, String date);

	DynamicReportVO getVerifyReortDetail(String userId, String checkStatus, String reporTypeId,
			Date startingReportDate, Date endingReportDate, String flag, boolean showSum, String newTypeId, String year);

	String exportReportExcel(DynamicReportVO report, String typeName);

	/**
	 * 获取可以取得上期指标数据行
	 */
	public List<Row> getLasttimeRowReportRow(User user, ReportType reportType, String timeDate, String quarterDate);

	/**
	 * 将可以获取上期数据的指标值设置到汇总表中
	 */
	public void addLasttimeCellReportToAccount(ReportType reportType, Map lastTimeIndicatorMap, Map accounting);

	List<SummaryReportType> queryReportTypeNew(String version, String type);

	String importUnitInfo(File file, String typeId, String year);

	List<Unit> queryNoUnits(String unitId, String roleId, String year, String typeId, String reportType);

	void deleteReport(String reportId);

	List<cn.com.generaldata.os.vo.ReportVO> reportAllQuery(String userId, String systemType, Date startingReportDate,
			Date endingReportDate);

	String buildExcel(String userId);

	boolean checkUserReport(String uid, String typeId);
	
	boolean checkOperatorIsBest(String userOperatorId);
	
	public List<ReportTypeUnit> reportTypeByUnit(String unitId);
	
	public boolean saveReportTypeUnit(String unitId, List<String> reportTypeIds, String[] delnoReportTypes);
	
	public List<Map> queryRwudstat(String year, boolean isNowYear);
}
